﻿#region

using System.Collections.Generic;
using System.Windows.Browser;

#endregion

namespace Radovici.Ctrls
{
    public static class HtmlManager
    {
        private static readonly IList<HtmlElement> _elements = new List<HtmlElement>();

        internal static void AttachHtmlElement(this HtmlElement element)
        {
            _elements.Add(element);
        }

        public static void ShowHtml()
        {
            foreach (HtmlElement element in _elements)
            {
                ShowHtmlElement(element);
            }
        }

        public static void ShowHtmlElement(this HtmlElement element)
        {
            HtmlPage.Window.Dispatcher.BeginInvoke(delegate { element.SetStyleAttribute("display", string.Empty); });
        }

        public static void HideHtml()
        {
            foreach (HtmlElement element in _elements)
            {
                HideHtmlElement(element);
            }
        }

        public static void HideHtmlElement(this HtmlElement element)
        {
            HtmlPage.Window.Dispatcher.BeginInvoke(delegate { element.SetStyleAttribute("display", "none"); });
        }
    }
}